import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import Api from '@/api/Api'
import VCharts from 'v-charts'
// 导入全局样式表
import './assets/css/global.css'
// 导入字体图标
import './assets/fonts/iconfont.css'
import './util/util.dialog'
// 导入NProgress进度条
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import axios from 'axios'
import vueTableExport from "@d2-projects/vue-table-export";
import sjUserSelect from '@/components/common/sj-user-select'
import sjApplyReceiveAmount from '@/components/common/sj-apply-receive-amount'
import sjSelectMemberChargeGooods from '@/components/common/sj-select-membercharge-goods'
import sjPagination from '@/components/common/sj-pagination'
import modal from '@/plugins/modal'


Vue.use(VCharts)
Vue.use(vueTableExport)
axios.defaults.baseURL = '/'
//axios.defaults.baseURL = 'http://debug.hxlx.com/'
// 拦截所有请求，为请求头添加token认证
axios.interceptors.request.use(config => {
  // 请求时开启进度条
  NProgress.start()

  // console.log(config)
  const userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
  config.headers.Authorization = userInfo ? userInfo.token : ''
  return config
})

axios.interceptors.response.use(config => {
  // 响应时结束进度度
  NProgress.done()
  return config
})

Vue.prototype.$http = axios
Vue.prototype.$api = Api;
Vue.prototype.$modal = modal

// 全局注册第三方表格组件
import ZkTable from 'vue-table-with-tree-grid'
Vue.component('tree-table', ZkTable)

// 工具库
import utils from './libs/utils'
Vue.prototype.$utils = utils

// 全局方法和全局变量
import globalFun from './util/global_function'
Vue.use(globalFun)
import globalVar from './util/global_variable'
Vue.prototype.$global = globalVar

// 导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
Vue.use(VueQuillEditor)
Vue.component('sj-user-select',sjUserSelect);
Vue.component('sj-apply-receive-amount', sjApplyReceiveAmount);
Vue.component('sj-select-membercharge-goods', sjSelectMemberChargeGooods);
Vue.component('sj-pagination',sjPagination);

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
